<?php
/**********************************************************************************
WIKINDX: Bibliographic Management system.
Copyright (C)

This program is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program;
if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

The WIKINDX Team 2006
sirfragalot@users.sourceforge.net
**********************************************************************************/
/**
* JS Format Bar class
* 
* @author	Mark Tsikanovski
* @editor	Mark Grimshaw
* @version	1
*/
class FORMATBAR
{
	function FORMATBAR()
	{
		include_once("core/html/FORM.php");
		include_once("core/html/MISC.php");
		include_once("core/html/TABLE.php");
		include_once("core/session/SESSION.php");
		$this->session = new SESSION();
		include_once("core/messages/UTF8.php");
		include_once("core/messages/MESSAGES.php");
		$this->messages = new MESSAGES();
		$this->utf8 = new UTF8();
	}
// The actual format bar
	function printFormatBar($fileName = FALSE, $databaseID = FALSE, $message = FALSE)
	{
// Set up localization of messages for the JSFB
		$bold = $this->messages->text("jsfb", "bold");
		$italic = $this->messages->text("jsfb", "italic");
		$underline = $this->messages->text("jsfb", "underline");
		$font = $this->messages->text("jsfb", "font");
		$fontSize = $this->messages->text("jsfb", "fontSize");
		$fontColour = $this->messages->text("jsfb", "fontColour");
		$justifyLeft = $this->messages->text("jsfb", "justifyLeft");
		$justifyCentre = $this->messages->text("jsfb", "justifyCentre");
		$justifyRight = $this->messages->text("jsfb", "justifyRight");
		$justifyFull = $this->messages->text("jsfb", "justifyFull");
		$indent = $this->messages->text("jsfb", "indent");
		$outdent = $this->messages->text("jsfb", "outdent");
		$subscript = $this->messages->text("jsfb", "subscript");
		$superscript = $this->messages->text("jsfb", "superscript");
		$cleanupSUWP = $this->messages->text("jsfb", "cleanupSUWP");
		$insertCite = $this->messages->text("jsfb", "insertCite");
		$insertMetadata = $this->messages->text("jsfb", "insertMetadata");
		$insertFootnote = $this->messages->text("jsfb", "insertFootnote");
		$insertCurrentDate = $this->messages->text("jsfb", "insertCurrentDate");
		$insertDate = $this->messages->text("jsfb", "insertDate");
		$statistics = $this->messages->text("jsfb", "statistics");
		$undo = $this->messages->text("jsfb", "undo");
		$redo = $this->messages->text("jsfb", "redo");
		$removeFormat = $this->messages->text("jsfb", "removeFormat");
		$insertUnorderedList = $this->messages->text("jsfb", "insertUnorderedList");
		$insertOrderedList = $this->messages->text("jsfb", "insertOrderedList");
		$insertUrl = $this->messages->text("jsfb", "insertUrl");
		$removeHyperlink = $this->messages->text("jsfb", "removeHyperlink");
		$insertImage = $this->messages->text("jsfb", "insertImage");
		$insertTable = $this->messages->text("jsfb", "insertTable");
		$insertSpecialCharacter = $this->messages->text("jsfb", "insertSpecialCharacter");
		$save = $this->messages->text("jsfb", "savePaper");
		$saveExport = $this->messages->text("jsfb", "saveExportPaper");
		$upperCase = $this->messages->text("jsfb", "upperCase");
		$lowerCase = $this->messages->text("jsfb", "lowerCase");
		$findReplace = $this->messages->text("jsfb", "findReplace");
		$find = $this->messages->text("jsfb", "find");
		$findAgain = $this->messages->text("jsfb", "findAgain");
		$insertSection = $this->messages->text("jsfb", "insertSection");
		$appendPaper = $this->messages->text("jsfb", "appendPaper");
$pString = <<< END
<table id="formatBar" border="0" cellpadding="0" cellspacing="0">
	<tr>
<!-- bold, italics, underline -->
		<td class="imageButtonCell">
			<div class="imageButton" autocomplete="OFF" id="bold" name="bold" onFocus="blur()" title="$bold" onClick="rteCommand('' + rte + '', 'bold', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/bold.gif" onFocus="blur()" />
			</div>
		</td>
		<td class="imageButtonCell">
			<div class="imageButton" autocomplete="OFF" id="italic" name="italic" onFocus="blur()" title="$italic" onClick="rteCommand('' + rte + '', 'italic', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/italic.gif" onFocus="blur()" />
			</div>
		</td>
		<td class="imageButtonCell">
			<div class="imageButton" autocomplete="OFF" id="underline" name="underline" onFocus="blur()" title="$underline" onClick="rteCommand('' + rte + '', 'underline', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/underline.gif" onFocus="blur()" />
			</div>
		</td>
<!-- font -->
		<td colspan="2">		  
			<select class="formatSelect" name="font" title="$font" id="fontname_paperText" 
			onchange="setOption('' + rte + '', this.id, false)">
				<option value="" selected="selected">$font</option>
				<option style="font-family:'Arial';" value="Arial">Arial</option>
				<option style="font-family:'Courier';" value="Courier">Courier</option>
				<option style="font-family:'Georgia';" value="Georgia">Georgia</option>
				<option style="font-family:'Helvetica';" value="Helvetica">Helvetica</option>
				<option style="font-family:'MS Sans Serif';" value="MS Sans Serif">MS Sans Serif</option>
				<option style="font-family:'MS Serif';" value="MS Serif">MS Serif</option>
				<option style="font-family:'Palatino';" value="Palatino">Palatino</option>
				<option style="font-family:'Tahoma';" value="Tahoma">Tahoma</option>
				<option style="font-family:'Trebuchet MS';" value="Trebuchet MS">Trebuchet MS</option>
				<option style="font-family:'Times New Roman';" value="Times New Roman">Times New Roman</option>
				<option style="font-family:'Verdana';" value="Verdana">Verdana</option>
			</select>
		</td>
<!-- font size - value matches HTML font size values -->
		<td colspan="2">
			<select class="formatSelect" name="size" title="$fontSize" id="fontsize_paperText" 
			onchange="setOption('' + rte + '', this.id, false)">
				<option value="" selected="selected">$fontSize</option>
				<option style="font-size:8;" value="1">9</option>
				<option style="font-size:10;" value="2">11</option>
				<option style="font-size:12;" value="3">12</option>
				<option style="font-size:14;" value="4">16</option>
				<option style="font-size:16;" value="5">20</option>
				<option style="font-size:18;" value="6">28</option>
				<option style="font-size:20;" value="7">36</option>
			</select>
		</td>
<!-- font colour -->
		<td colspan="2">
			<select class="formatSelect" name="color" title="$fontColour" id="forecolor_paperText" 
			onChange="setOption('' + rte + '', this.id, false)">
				<option value="" selected="selected">$fontColour</option>
				<option style="color:white; background-color: black" value="black">Black</option>
				 <option style="color:white; background-color: silver" value="silver">Silver</option>
				<option style="color:white; background-color: gray" value="gray">Gray</option>
				<option style="color:black; background-color: white" value="white">White</option>
				<option style="color:white; background-color: maroon" value="maroon">Maroon</option>
				<option style="color:white; background-color: red" value="red">Red</option>
				<option style="color:white; background-color: purple" value="purple">Purple</option>
				<option style="color:white; background-color: fuchsia" value="fuchsia">Fuchsia</option>
				<option style="color:white; background-color: green" value="green">Green</option>
				<option style="color:white; background-color: lime" value="lime">Lime</option>
				<option style="color:white; background-color: olive" value="olive">Olive</option>
				<option style="color:white; background-color: yellow" value="yellow">Yellow</option>
				<option style="color:white; background-color: navy" value="navy">Navy</option>
				<option style="color:white; background-color: blue" value="blue">Blue</option>
				<option style="color:white; background-color: teal" value="teal">Teal</option>
				<option style="color:white; background-color: aqua" value="aqua">Aqua</option>						
			</select>
		</td>
<!-- justify -->
		<td>
			<div class="imageButton" autocomplete="OFF" id="justifyleft" name="justifyleft" onFocus="blur()" title="$justifyLeft" onClick="rteCommand('' + rte + '', 'justifyleft', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/justify_left.gif" onFocus="blur()" />
			</div>	  
		</td>
		<td>
			<div class="imageButton" autocomplete="OFF" id="justifycenter" name="justifycenter" onFocus="blur()" title="$justifyCentre" onClick="rteCommand('' + rte + '', 'justifycenter', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/justify_center.gif" onFocus="blur()" />
			</div>	  
		</td>
		<td>
			<div class="imageButton" autocomplete="OFF" id="justifyright" name="justifyright" onFocus="blur()" title="$justifyRight" onClick="rteCommand('' + rte + '', 'justifyright', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/justify_right.gif" onFocus="blur()" />
			</div>	  
		</td>
		<td>
			<div class="imageButton" autocomplete="OFF" id="justifyfull" name="justifyfull" onFocus="blur()" title="$justifyFull" onClick="rteCommand('' + rte + '', 'justifyfull', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/justify_full.gif" onFocus="blur()" />
			</div>	  
		</td>		
<!-- subscript and superscript -->
		<td>
			<div class="imageButton" autocomplete="OFF" id="subscript" name="subscript" onFocus="blur()" title="$subscript" onClick="rteCommand('' + rte + '', 'subscript', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/subscript.gif" onFocus="blur()" />
			</div>	  
		</td>
		<td>			
			<div class="imageButton" autocomplete="OFF" id="superscript" name="superscript" onFocus="blur()" title="$superscript" onClick="rteCommand('' + rte + '', 'superscript', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/superscript.gif" onFocus="blur()" />
			</div>	
		</td>	
<!-- indent and outdent -->
		<td>
			<div class="imageButton" autocomplete="OFF" id="indent" name="indent" onFocus="blur()" title="$indent" onClick="rteCommand('' + rte + '', 'indent', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/indent.gif" onFocus="blur()" />
			</div>	  
		</td>
		<td>
			<div class="imageButton" autocomplete="OFF" id="outdent" name="outdent" onFocus="blur()" title="$outdent" onClick="rteCommand('' + rte + '', 'outdent', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/outdent.gif" onFocus="blur()" />
			</div>	  
		</td>			
<!-- various types of character manipulation and string insertion -->

		<td>
			<div class="imageButton" autocomplete="OFF" id="upperCase" name="upperCase" onFocus="blur()" title="$upperCase" onClick="upperCase('paperText')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/ucase.gif" onFocus="blur()" />
			</div>
		</td>
		<td>
			<div class="imageButton" autocomplete="OFF" id="lowerCase" name="lowerCase" onFocus="blur()" title="$lowerCase" onClick="lowerCase('paperText')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/lcase.gif" onFocus="blur()" />
			</div>		
		</td>
<!-- Find -->
<!--
		<td>			
			<div class="imageButton" autocomplete="OFF" id="find" name="find" onFocus="blur()" title="$find" onClick="dlgFind('' + rte + '', 'find', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/find.gif" onFocus="blur()" />
			</div>	
		</td>
		<td>			
			<div class="imageButton" autocomplete="OFF" id="findAgain" name="findAgain" onFocus="blur()" title="$findAgain" onClick="findTextAgain('paperText')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/findagain.gif" onFocus="blur()" />
			</div>	
		</td>
-->
		<td>			
			<div class="imageButton" autocomplete="OFF" id="findReplace" name="findReplace" onFocus="blur()" title="$findReplace" onClick="dlgFindReplace('' + rte + '', 'findReplace', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/replace.gif" onFocus="blur()" />
			</div>	
		</td>
	</tr>
		
	<tr>
<!-- cite tag -->		
	  <td>
			<div class="imageButton" autocomplete="OFF" id="cite" name="cite" onFocus="blur()" title="$insertCite" onClick="openCiteWindow('index.php?action=citeDisplay&amp;citeMethod=suwp')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/cite.gif" onFocus="blur()" />
			</div>		
		</td>
<!-- insert metadata -->
		<td>		
			<div class="imageButton" autocomplete="OFF" id="metadata" name="metadata" onFocus="blur()" title="$insertMetadata" onClick="openMetadataWindow('index.php?action=suwpMetadataDisplay&amp;method=hdnpaperText')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/metadata.gif" onFocus="blur()" />
			</div>		
		</td>
<!-- insert footnote -->		
		<td>	 
			<div class="imageButton" autocomplete="OFF" id="insertFootnote" name="insertFootnote" onFocus="blur()" title="$insertFootnote" onClick="dlgFootnote('' + rte + '', 'footnote', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/insert_footnote.gif" onFocus="blur()" />
			</div>
		</td>

		<td>			
			<div class="imageButton" autocomplete="OFF" id="timestamp" name="timestamp" onFocus="blur()" title="$insertCurrentDate" onClick="timestamp()" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/timestamp.gif" onFocus="blur()" />
			</div>
		</td>
		<td>
			<div class="imageButton" autocomplete="OFF" id="calendar" name="calendar" onFocus="blur()" title="$insertDate" onClick="calendar()" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/calendar.gif" onFocus="blur()" />
			</div>		
		</td>		
		<td>
			<div class="imageButton" autocomplete="OFF" id="undo" name="undo" onFocus="blur()" title="$undo" onClick="rteCommand('' + rte + '', 'undo', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/undo.gif" onFocus="blur()" />
			</div>		
		</td>
		<td>		
			<div class="imageButton" autocomplete="OFF" id="redo" name="redo" onFocus="blur()" title="$redo" onClick="rteCommand('' + rte + '', 'redo', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/redo.gif" onFocus="blur()" />
			</div>
		</td>
<!-- remove design mode formatting -->
		<td>		
			<div class="imageButton" autocomplete="OFF" id="removeFormat" name="removeFormat" onFocus="blur()" title="$removeFormat" onClick="rteCommand('' + rte + '', 'removeFormat', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/unformat.gif" onFocus="blur()" />
			</div>
		</td>
<!-- lists -->
		<td>			
			<div class="imageButton" autocomplete="OFF" id="insertunorderedlist" name="insertunorderedlist" onFocus="blur()" title="$insertUnorderedList" onClick="rteCommand('' + rte + '', 'insertunorderedlist', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/bullist.gif" onFocus="blur()" />
			</div>	
		</td>
		<td>			
			<div class="imageButton" autocomplete="OFF" id="insertorderedlist" name="insertorderedlist" onFocus="blur()" title="$insertOrderedList" onClick="rteCommand('' + rte + '', 'insertorderedlist', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/numlist.gif" onFocus="blur()" />
			</div>	
		</td>
<!-- URL -->
		<td>
			<div class="imageButton" autocomplete="OFF" id="url" name="url" onFocus="blur()" title="$insertUrl" onClick="dlgInsertLink('' + rte + '', 'link', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/link.gif" onFocus="blur()" />
			</div>		
		</td>
<!-- remove hyperlinks -->
		<td>	 
			<div class="imageButton" autocomplete="OFF" id="removeHyperlink" name="removeHyperlink" onFocus="blur()" title="$removeHyperlink" onClick="rteCommand('' + rte + '', 'unLink', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/unlink.gif" onFocus="blur()" />
			</div>
		</td>		
<!-- image -->
		<td>
			<div class="imageButton" autocomplete="OFF" id="image" name="image" onFocus="blur()" title="$insertImage" onClick="addImage('' + rte + '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/image.gif" onFocus="blur()" />
			</div>
		</td>
<!-- table -->
		<td>
			<div class="imageButton" autocomplete="OFF" id="table" name="table" onFocus="blur()" title="$insertTable" onClick="dlgInsertTable('' + rte + '', 'table', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/instable.gif" onFocus="blur()" />
			</div>
		</td>
<!-- special chars -->
		<td>
			<div class="imageButton" autocomplete="OFF" id="spChar_paperText" name="spChar" onFocus="blur()" title="$insertSpecialCharacter" onClick="dlgSpChar('' + rte + '', 'spChar', '')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/specialchar.gif" onFocus="blur()" />
			</div>		
	  </td>
<!-- insert section -->
		<td>
			<div class="imageButton" autocomplete="OFF" id="insertSection" name="insertSection" onFocus="blur()" title="$insertSection" onClick="insertSection('paperText')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/insertsection.gif" onFocus="blur()" />
			</div>		
		</td>
<!-- appendPaper -->
		<td>		
			<div class="imageButton" autocomplete="OFF" id="appendPaper" name="appendPaper" onFocus="blur()" title="$appendPaper" onClick="openAppendPaperWindow('index.php?action=suwpAppendPaperDisplay&amp;method=hdnpaperText')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/appendpaper.gif" onFocus="blur()" />
			</div>		
		</td>
<!-- cleanup source HTML -->
		<td>			
			<div class="imageButton" autocomplete="OFF" id="cleanupSUWP" name="cleanupSUWP" onFocus="blur()" title="$cleanupSUWP" onClick="cleanupSUWP('paperText')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/cleanup.gif" onFocus="blur()" />
			</div>	
		</td>
<!-- Statistics -->
		<td>
			<div class="imageButton" autocomplete="OFF" id="stats" name="stats" onFocus="blur()" title="$statistics" onClick="stats(rte)" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/stats.gif" onFocus="blur()" />
			</div>		
		</td>
<!-- save dialogue -->
		<td>
			<div class="imageButton" autocomplete="OFF" id="save" name="save" onFocus="blur()" title="$save" onClick="openPopUpSaveDialogue('$fileName', '$databaseID')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/save.gif" onFocus="blur()" />
			</div>
		</td>
<!-- save and Export dialogue -->
		<td>
			<div class="imageButton" autocomplete="OFF" id="saveExport" name="saveExport" onFocus="blur()" title="$saveExport" onClick="openPopUpSaveExportDialogue('$fileName', '$databaseID')" onMouseover="mouseOverImageButton(this.id,1)" onMouseout="mouseOverImageButton(this.id,0)" onMouseDown="mouseDownImageButton(this.id,1)" onMouseUp="mouseDownImageButton(this.id,0)">
				<img src="./core/wp/JsFormatBar/ButtonImages/saveExport.gif" onFocus="blur()" />
			</div>
		</td>
	</tr>
</table>
END;
// Add table for font format indicator
//		$formatIndicator = $this->formatIndicator();
// Add table for save options
		$saveString = $this->saveOptions($fileName, $databaseID, $message);
// Encapsulate both tables in one table
		$table = TABLE::tableStart();
		$table .= TABLE::trStart();
		$table .= TABLE::td($pString);
//		$table .= TABLE::td($formatIndicator);
		$table .= TABLE::td($saveString);
		$table .= TABLE::trEnd();
		$table .= TABLE::tableEnd();
		return $table;
	}

	function formatIndicator()
	{
		$pString = TABLE::tableStart();
		$pString .= TABLE::trStart();
		$pString .= "<td id=\"formatIndicator\" name=\"formatIndicator\" align =\"left\">Times New Roman</td>";
		$pString .= TABLE::trEnd();
		$pString .= TABLE::tableEnd();
		return $pString;
	}

	function saveOptions($fileName, $databaseID, $message)
	{
		$pString = TABLE::tableStart();
// Cell for success messages on saving (updated in javascript)
		if(!$message)
			$message = "&nbsp;";
		$pString .= TABLE::trStart();
		$pString .= "<td id=\"suwpMessage\" name=\"suwpMessage\" align =\"left\">$message</td>";
		$pString .= TABLE::trEnd();
// Cell for hyperlink to exported file (updated in javascript)
		$pString .= TABLE::trStart();
		$pString .= "<td id=\"exportFile\" name=\"exportFile\" align =\"left\">&nbsp;</td>";
		$pString .= TABLE::trEnd();
// Cell for restoring menu bar (updatedin javascript)
		$pString .= TABLE::trStart();
		$pString .= "<td id=\"menuRestore\" name=\"menuRestore\" align =\"left\">" . 
			MISC::a('required', $this->messages->text("wp", "menuRestore"), 'javascript:menuRestore()') . 
			"</td>";
		$pString .= TABLE::trEnd();
		$pString .= TABLE::tableEnd();
		return $pString;
	}
	function printPaper()
	{
		$tmpString = base64_decode($this->session->getVar("wp_text"));
// safe code for preloading in the RTE
// Convert UTF-8
		$tmpString = $this->utf8->decodeUtf8($tmpString);
//convert all types of single quotes
		$tmpString = str_replace(chr(145), chr(39), $tmpString);
		$tmpString = str_replace(chr(146), chr(39), $tmpString);
		$tmpString = str_replace("'", "&#39;", $tmpString);
//convert all types of double quotes
		$tmpString = str_replace('"', "&#34;", $tmpString);
		$tmpString = str_replace(chr(147), chr(34), $tmpString);
		$tmpString = str_replace(chr(148), chr(34), $tmpString);
//strip carriage returns & line feeds
		$tmpString = str_replace(chr(10), " ", $tmpString);
		$text = str_replace(chr(13), " ", $tmpString);
// iFrame for WYSIWYG editor
// onFocus=\"getInputId(this, 'Focus')\" causes javascript bugs in IE so removed for v3.6.1.  Doesn't seem to do any harm.
		$pString = "<iframe class=\"suwpOuter\" id=\"paperText\" name=\"paperText\" align=\"center\" 
			src=\"core/wp/JsFormatBar/blank.htm\" 
			onKeydown=\"getInputId(this, event)\" onFocus=\"this.status='focused'\" onBlur=\"this.status='not focused'\"></iframe>";
//		$pString = "<iframe class=\"suwpOuter\" id=\"paperText\" name=\"paperText\" align=\"center\" 
//			src=\"core/wp/JsFormatBar/blank.htm\" onKeydown=\"getInputId(this, event)\"  onFocus=\"getInputId(this, 'Focus')\"></iframe>";
// Load CSS file and pass to javascript
		$template = $this->session->getVar("setup_template");
		$template = "templates/$template/" . $template . ".css";
$pString .= <<< END
<script language="JavaScript" type="text/javascript">
<!--
enableDesignMode('paperText', "$text", "$template", false);
document.getElementById('menuRestore').style.visibility = 'hidden';
//-->
</script>
END;
	return $pString;
	}
}
?>
